"use strict";

const { TaiSpider } = require("tai-spider");

class SXGovNewsSpider extends TaiSpider {
  constructor(options = {}) {
    super(options);
    this.name = "sx-gov-detail";
    this.debug = true;
    this.start_urls = options.start_urls;
  }

  *parse(response) {
    yield {
      title: response.css("table").get(0).css("table tr td").get(0).extract(),
      content: response.css("table").get(1).css("table tr td").get(0).extract(),
      partment: response
        .css("table")
        .get(2)
        .css("table tr td")
        .get(1)
        .extract(),
      start: response.css("table").get(2).css("table tr td").get(2).extract(),
      end: response.css("table").get(2).css("table tr td").get(3).extract(),
      href: this.start_urls[0],
    };
  }
}

module.exports = SXGovNewsSpider;
